/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ApplyPanel.java
 *
 * Created on Aug 27, 2010, 5:44:55 PM
 */

package org.apache.directory.http.client.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.apache.directory.http.client.ui.callback.ConfigModificationHandler;

/**
 *
 * @author kayyagari
 */
public class ApplyPanel extends javax.swing.JPanel implements ActionListener {

    private ConfigModificationHandler handler;

    /** Creates new form ApplyPanel */
    public ApplyPanel() {
        initComponents();
        btnApply.addActionListener(this);
        btnCancel.addActionListener(this);
    }

    public void setModificationHandler( ConfigModificationHandler handler )
    {
        this.handler = handler;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnCancel = new javax.swing.JButton();
        btnApply = new javax.swing.JButton();

        btnCancel.setText("Cancel");
        btnCancel.setEnabled(false);
        add(btnCancel);

        btnApply.setText("Apply");
        btnApply.setEnabled(false);
        add(btnApply);
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnApply;
    private javax.swing.JButton btnCancel;
    // End of variables declaration//GEN-END:variables

    public void actionPerformed(ActionEvent e) {

        if( handler == null )
        {
            return;
        }

        Object src = e.getSource();

        if( src == btnApply )
        {
            handler.apply();;
        }
 else if ( src == btnCancel )
        {
     handler.cancel();
 }

    }

}
